/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.colswe.solestac.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Column;
import javax.persistence.Basic;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Entity;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Operador
 */
@Entity
@Table(name = "REQUEST")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Request.findAll", query = "SELECT r FROM Request r"),
    @NamedQuery(name = "Request.findById", query = "SELECT r FROM Request r WHERE r.id = :id"),
    @NamedQuery(name = "Request.findByFilingDate", query = "SELECT r FROM Request r WHERE r.filingDate = :filingDate"),
    @NamedQuery(name = "Request.findByAcademicPeriod", query = "SELECT r FROM Request r WHERE r.academicPeriod = :academicPeriod"),
    @NamedQuery(name = "Request.findByDecision", query = "SELECT r FROM Request r WHERE r.decision = :decision") })
public class Request implements Serializable {
    
    /**Version of the Serializable interface.
     */
    private static final long serialVersionUID = 1L;
    /**ID from the request.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    /**Date from the request.
     */
    @Column(name = "FILING_DATE")
    @Temporal(TemporalType.DATE)
    private Date filingDate;
    /**Academic Period from the request.
     * 
     */
    @Column(name = "ACADEMIC_PERIOD")
    private String academicPeriod;
    /**Decision about the request.
     */
    @Column(name = "DECISION")
    private String decision;
    /**ID from the student related with the request.
     */
    @JoinColumn(name = "STUDENT_ID", referencedColumnName = "ID")
    @ManyToOne
    private Student studentId;
    /**ID to identify the type of request.
     */
    @JoinColumn(name = "TYPE_ID", referencedColumnName = "ID")
    @ManyToOne
    private RequestType typeId;
    /**ID to identify the actual instance of the request.
     */
    @JoinColumn(name = "INSTANCE_ID", referencedColumnName = "ID")
    @ManyToOne
    private Instance instanceId;
    /**The support docs from the request.
     */
    @Column(name = "SUPPORTDOCS")
    private String supportdocs;
    
    /**Default Constructor.
     */
    public Request() {
    }

    /**Constructor using the id.
     * @param newId The Id value
     */
    public Request(final Long newId) {
        this.id = newId;
    }

    /**Getter for Id.
     * @return The Id value
     */
    public Long getId() {
        return id;
    }

    /**Setter for Id.
     * @param newId The new value.
     */
    public void setId(final Long newId) {
        this.id = newId;
    }

    /**Getter for Filing Date.
     * @return The FilingDate value
     */
    public String getFilingDate() {
        return filingDate.toString();
    }

    /**Setter for Filing Date.
     * @param newFilingDate The new value
     */
    public void setFilingDate(final Date newFilingDate) {
        this.filingDate = newFilingDate;
    }

    /**Getter for Academic Period.
     * @return The AcademicPeriod value
     */
    public String getAcademicPeriod() {
        return academicPeriod;
    }

    /**Setter for Academic Period.
     * @param newAcademicPeriod The new value
     */
    public void setAcademicPeriod(final String newAcademicPeriod) {
        this.academicPeriod = newAcademicPeriod;
    }

    /**Getter for Decision.
     * @return The decision value
     */
    public String getDecision() {
        return decision;
    }

    /**Setter for Decision.
     * @param newDecision The new value
     */
    public void setDecision(final String newDecision) {
        this.decision = newDecision;
    }

    /**Getter for StudentId.
     * @return The StudentId value
     */
    public Student getStudentId() {
        return studentId;
    }

    /**Setter for StudentId.
     * @param newStudentId The new value
     */
    public void setStudentId(final Student newStudentId) {
        this.studentId = newStudentId;
    }

    /**Getter for TypeId.
     * @return The TypeId value.
     */
    public RequestType getTypeId() {
        return typeId;
    }

    /**Setter for TypeId.
     * @param newTypeId The new value.
     */
    public void setTypeId(final RequestType newTypeId) {
        this.typeId = newTypeId;
    }

    /**Getter for InstanceId.
     * @return The InstanceId value.
     */
    public Instance getInstanceId() {
        return instanceId;
    }

    /**Setter for InstanceId.
     * @param newInstanceId The new value
     */
    public void setInstanceId(final Instance newInstanceId) {
        this.instanceId = newInstanceId;
    }

    /**Assignment of the hashcode.
     * @return The hash.
     */
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    /**Compare two Request objects based on the Id.
     * @param object The object to compare
     * @return The result of the comparison.
     */
    @Override
    public boolean equals(final Object object) {
        if (!(object instanceof Request)) {
            return false;
        }
        Request other = (Request) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    /**Convert to string using the Id.
     * @return The string
     */
    @Override
    public String toString() {
        return "org.colswe.solestac.entity.Request[ id=" + id + " ]";
    }

    /**Getter for Support Docs.
     * @return The SupportDocs value
     */
    public String getSupportdocs() {
        return supportdocs;
    }
    
    /**Setter for SupportDocs.
     * @param newSupportdocs The new value
     */
    public void setSupportdocs(final String newSupportdocs) {
        this.supportdocs = newSupportdocs;
    }   
}
